﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Enums;
using RoadTeam.Model;
using RoadTeam.DAL;
using RoadTeam.SysInterface;

namespace RoadTeam.BsSystem.RM
{
    public class RmCust_Sys : IRmCust
    {
        public DataTable GetCustData(String Where)
        {
            String StrSql = @"SELECT TbRmCust.CustID,CustName,CustCode,BirthDate,Email,
Tel,RelaType,TbRmUnit.UnitIdentifier,TbRmCust.CustIdentifier FROM TbRmCust 
Inner JOIN TbRmCustUnitRela
on TbRmCust.CustID =TbRmCustUnitRela.CustID
INNER join TbRmUnit on TbRmUnit.UnitID=TbRmCustUnitRela.UnitID
WHERE TbRmUnit.UnitIdentifier  IN (" + Where + ")";
            DataTable dt = DbFactory.CreateInstance().CreateDb().
                ExecuteStrQuery(StrSql, CommandType.Text, GlobalConfig.RtConnectionString);
            return dt;
        }

        public bool UpdateCustData(DataTable dt)
        {
            return TbRmCust.Update(dt, GlobalConfig.RtConnectionString);
        }
    }
}
